package com.huaqing.games.impl;

import com.huaqing.games.GameStandard;
import com.huaqing.result.ResultOperation;
import com.huaqing.result.Result;
import com.huaqing.result.impl.ResultOperationImpl;

/**
 * @program: javatrainingfirstweek
 * @Description:
 * @author: Mr.Cheng
 * @date: 2022/4/16 11:17 下午
 */
public class GameStandardImpl implements GameStandard {
    /**
     * @param person
     * @param computer
     * @Description: 石头剪刀布游戏规则 {"剪刀":1, "石头":2,"布":3}
     * 人-电脑 = 0（平）；人-电脑 = 1（人胜）；人-电脑 = -2（人胜）;
     *                  人-电脑 = -1（电脑胜）；人-电脑 = 2（电脑胜）
     * 总结：人-电脑 = 0（平）; (人-电脑+3)%3 = 1（人胜）; (人-电脑+3)%3 = 2（电脑胜）
     * @Param: [person, computer]
     * @return: com.huaqing.pojo.Result
     * @Author: Mr.Cheng
     * @Date: 2022/4/16 4:52 下午
     */
    @Override
    public Result rockPaperScissors(int person, int computer) {
        Result result = new Result();
        ResultOperation operation = new ResultOperationImpl();
        switch ((person - computer + 3)%3){
            case 0:
                result = operation.rockPaperScissorsByPersonAndComputerDraws();
                break;
            case 1:
                result = operation.rockPaperScissorsByPersonWin();
                break;
            case 2:
                result = operation.rockPaperScissorsByComputerWin();
                break;
            default:
        }
        return result;
    }
}
